#! /usr/bin/python

def genAll(alln):    
    result = []
    for n in alln:
	if len(n) == 1: upper = 10 - n[0]
	else: upper = 10 - n[0] - n[1]
	for i in range(upper):
	    new = [n[len(n) - 1], i]
	    result.append(new)
    return result

def genNext(alln, length, increment):    
    result = [0 for i in range(len(alln))]
    for n in alln:
	upper = 10 - n[0] - n[1]
	for i in range(upper):
	    new = [n[len(n) - 1], i]
	    j = alln.index(new)
	    result[j] += increment[alln.index(n)]
    return result

alln = []
for i in range(0, 10):
    alln.append([i])
alln = genAll(alln)


startn = []
for i in range(1, 10):
    startn.append([i])
startn = genAll(startn) #length 2

print startn
increment = []
for n in alln:
    increment.append(startn.count(n))

length = 2
while(length < 20):
     increment = genNext(alln, length, increment)
     #print increment
     length += 1

print increment
print sum(increment)
#print alln
